$(function () {
    var prefix = window.location.pathname.substr( 0, window.location.pathname.toLowerCase().lastIndexOf( "/extensions" ) + 1 );
    var config = {
        host: window.location.hostname,
        prefix: prefix,
        port: window.location.port,
        isSecure: window.location.protocol === "https:"
    };
    require.config( {
        baseUrl: ( config.isSecure ? "https://" : "http://" ) + config.host + (config.port ? ":" + config.port : "") + config.prefix + "resources",
		waitSeconds: 0
    } );

    require( ["js/qlik","./swiper.min.js"], function (qlik, Swiper) {

        qlik.theme.apply("theme-white");
        qlik.setOnError( function ( error ) {
            console.warn(error.message);
        } );

        // 初始化顶部菜单栏
        var menuBi = new Swiper('.bi_menu', {
            freeMode : false,
            slidesPerView : 'auto',
            spaceBetween:0
        });
        $('.menu_btn').on('click',function(){
            $('.menu_btn.active').removeClass('active');
            $(this).addClass('active');
            contentBi.slideTo($(this).index());
            document.body.scrollTop = document.documentElement.scrollTop = 0;
            if($(this).index() == '0'){
                //产品-仪表盘
                app.getObject('CurrentSelections','CurrentSelections');
                app.getObject('QV01','kEjm');
                app.getObject('QV02','NzXKT');
                app.getObject('QV03','aJHyWbU');
                app.getObject('QV04','zFjMG');
                app.getObject('QV05','BzAmYm');
                app.getObject('QV06','FpvQeDN');
            }
            if($(this).index() == '1'){
                app.getObject('QV10','DZCXTs');
            }
        });

        //初始化内容
        var contentBi = new Swiper('.bi_content', {
            autoHeight: true,
            noSwiping : true
        });
        // 侧边栏弹出
        $('.side_btn').click(function () {
            $('.weidu_cover').fadeIn();
            $('.weidu_box').addClass('weidu_active');
            // 加载过滤条件
            app.getObject('QV100','yMnvCU');
            app.getObject('QV101','tPkAk');
            app.getObject('QV102','wNPm');
            app.getObject('QV103','gPkDfX');
            app.getObject('QV104','JhqQHWt');
            app.getObject('QV105','SGhSzJ');
            document.querySelector('body').style.overflow = 'hidden';
        });
        // 关闭侧边栏
        $('.weidu_cover').click(function () {
            $('.weidu_cover').fadeOut();
            $('.weidu_box').removeClass('weidu_active');
            document.querySelector('body').style.overflow = 'auto';
        });

        var app = qlik.openApp('人才透视分析.qvf', config);
        //初始化数据
        app.getObject('CurrentSelections','CurrentSelections');
        app.getObject('QV01','kEjm');
        app.getObject('QV02','NzXKT');
        app.getObject('QV03','aJHyWbU');
        app.getObject('QV04','zFjMG');
        app.getObject('QV05','BzAmYm');
        app.getObject('QV06','FpvQeDN');
    });
});